/**
 * 树的层序遍历
*/

#include "tree.c"

#define QueueElementType TreeNode*
#include "Queue.c"

#ifndef TREE_TRAVERSAL_LEVEL
#define TREE_TRAVERSAL_LEVEL

void LevelTraversal(Tree root) {
    if (root == NULL) {
        return;
    }
    int isp = 0;
    Queue* queue = createQueue();
    enQueue(queue, root);
    while (!isEmptyQueue(queue)) {
        TreeNode* tn = deQueue(queue);
        visitTreeNode(tn);
        if (tn->left != NULL) {
            enQueue(queue, tn->left);
        }
        if (tn->right != NULL) {
            enQueue(queue, tn->right);
        }
    }
    freeQueue(queue);
}

#endif 
